<!-- 左侧面板 -->
<template>
  <ModelTile class="sdly" title="重要指标" @onMore="onMore" :is-download="false" :is-more="false">
    <div class="sdly-item" v-for="item in listData" :key="item.title">
      <div class="desc">
        <div>
          <span>{{ sectorNameTypes.find((type) => type.value == item.sectorName)?.label }}</span>
        <span class="compInfo">实际完成：100亿 / 目标：120亿</span>
      </div>
        <span
          ><span
            class="baifengbiF"
            >{{ item.targetCr }}%</span
          ></span
        >
      </div>
      <div class="pogress">
        <div class="pogress-box">
          <div
            class="pogress-mark"
            :class="[item.targetCr <= 20 ? 'pogress20' : item.targetCr <= 40 ? 'pogress40' : '']"
            :style="{ width: item.targetCr + '%' }"
          ></div>
          <div class="pogress-block" :style="{ left: item.targetCr + '%' }"></div>
        </div>
      </div>
    </div>
  </ModelTile>
</template>

<script lang="ts">
import { ref, defineComponent, computed ,inject} from 'vue'
import ModelTile from '@/components/modleTitle/index.vue'
import { useRouter } from 'vue-router'
const httpApi: any = inject('$http')
const listDataBank = ref([])
function getInitData() {
  /**
  httpApi.cityFixedAssets1Api
    .keyIndicators({})
    .then((res: any) => {
      if (res.success) {
        listDataBank.value = res.body || []
      } else {
        console.error('系统异常')
      }
    })
    .catch((err: any) => {
      console.error(err || '系统异常')
    })
	*/
    listDataBank.value = [
          { sectorName: '0', aeYtd: '100', targetYtd: '120', targetCr: 83 },
          { sectorName: '2', aeYtd: '100', targetYtd: '120', targetCr: 83 },
          { sectorName: '1', aeYtd: '30', targetYtd: '120', targetCr: 25 },
          { sectorName: '4', aeYtd: '60', targetYtd: '120', targetCr: 50 },
          { sectorName: '3', aeYtd: '20', targetYtd: '150', targetCr: 13 },
          { sectorName: '5', aeYtd: '100', targetYtd: '120', targetCr: 83 },
          { sectorName: '6', aeYtd: '30', targetYtd: '120', targetCr: 25 },
          { sectorName: '8', aeYtd: '60', targetYtd: '120', targetCr: 50 },
          { sectorName: '7', aeYtd: '20', targetYtd: '150', targetCr: 13 },
          { sectorName: '10', aeYtd: '30', targetYtd: '120', targetCr: 25 },
          { sectorName: '9', aeYtd: '60', targetYtd: '120', targetCr: 50 },
          { sectorName: '11', aeYtd: '20', targetYtd: '150', targetCr: 13 }
        ];
}
getInitData()

export default defineComponent({
  name: 'sdly',
  components: {
    ModelTile
  },
  props: {
    // 父级统计数据
    statAllData: {
      type: Object,
      default: {}
    }
  },
  setup(props) {
    const router = useRouter()
    const sectorNameTypes = [
      { value: '0', label: '广州市' },
      { value: '1', label: '越秀区' },
      { value: '2', label: '海珠区' },
      { value: '3', label: '白云区' },
      { value: '4', label: '荔湾区' },
      { value: '5', label: '黄埔区' },
      { value: '6', label: '增城区' },
      { value: '7', label: '从化区' },
      { value: '8', label: '南沙区' },
      { value: '9', label: '天河区' },
      { value: '10', label: '番禺区' },
      { value: '11', label: '花都区' }
    ]
	const listData1 = listDataBank;
    const listData = computed(
      () =>
        props.statAllData?.sectorInfos || listData1.value
    )
    // 跳转页面
    function onMore() {
      console.log('跳转页面')
    }
    return {
      listData,
      sectorNameTypes,
      onMore
    }
  }
})
</script>
<style lang="scss" scoped>
.sdly {
  color: #fff;
  margin-bottom: 64vh * $Bh;

  :deep(.content) {
    padding: 20vh * $Bh 32vw * $w 42vh * $Bh 32vw * $w;
    height: 1280vh * $Bh;
    border-radius: 12vh * $Bh;
    background-color: initial;
  }

  .sdly-item {
    height: 75vh * $Bh;
    .title {
      font-size: 28vh * $Bh;
      line-height: 1;
      margin-bottom: 10vh * $Bh;
    }

    .desc {
      font-size: 32vh * $Bh;
      line-height: 54vh * $Bh;
      display: flex;
      justify-content: space-between;
      margin-bottom: 5vh * $Bh;
      .compInfo {
        margin-left: 24vw * $Bw;
      }
      .baifengbiF {
        color: #fff;
        margin-left: 2px;
      }
      .baifengbi20 {
        color: #f7b0a2;
        margin-left: 2px;
      }
      .baifengbi40 {
        color: #a28051;
        margin-left: 2px;
      }
      .baifengbi {
        color: red;
        margin-left: 2px;
      }
    }

    .pogress {
      height: 16vh * $Bh;
      background: #525f7f;
      .pogress-box {
        height: 12vh * $Bh;
        position: relative;

        .pogress-mark {
          height: 12vh * $Bh;
          background: linear-gradient(to right, #188282, #a6fdfd);

          &.pogress20 {
            background: linear-gradient(to right, #862e1c, #f7b0a2);
          }

          &.pogress40 {
            background: linear-gradient(to right, #845a1a, #f6d5a1);
          }
        }

        .pogress-block {
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          background-color: #fff;
          box-shadow: 0 0 6vh * $Bh 0 #fff;
          width: 6vw * $w;
          height: 16vh * $Bh;
        }
      }
    }

    & + .sdly-item {
      margin-top: 30vh * $Bh;
    }
  }
}
</style>
